﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CocisDAL;
using CocisModel;
using CocisModel.Common;
using System.Data;
using CocisWeb.src;

namespace CocisWeb.ManageAsset
{
    public partial class AddIPRange : BasePage
    {
        public AssetDAL dal = new AssetDAL();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.txtStartIP.Focus();
            }
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            Asset.IPRangeDataTable dt = new Asset.IPRangeDataTable();
            Asset.IPRangeRow rows = dt.NewIPRangeRow();
            Guid gd = new Guid();
            rows.IPRangeID = gd;
            rows.IPRange = this.txtIPRange.Text;
            rows.StartIP = this.txtStartIP.Text;
            rows.EndIP = this.txtEndIP.Text;
            rows.IPType = this.txtIPType.Text;
           
            dt.Rows.Add(rows);
            dt.AcceptChanges();

            int temp = dal.AddIPRange(dt);
            if (temp > 0)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "a", "<script language=javascript>alert('添加成功！')</script>");
                this.txtStartIP.Text = "";
                this.txtEndIP.Text = "";
                this.txtIPType.Text = "";
               
               

            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "b", "<script language=javascript>alert('添加失败！')</script>");
 
            }


        }
       
    }
}
